package com.hyh.util;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.app.NotificationCompat;

import com.hyh.videochat.R;


/**
 * Created by Administrator on 2019/1/27.
 */

public class NotificationUtil {

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    public static Notification createNotification(Context context, String str){
        String channelName = "ChatVideo";
        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder builder;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
            NotificationChannel channel = new NotificationChannel(channelName,channelName, NotificationManager.IMPORTANCE_DEFAULT);
            manager.createNotificationChannel(channel);
            builder = new Notification.Builder(context,channelName);
        }else{
            builder = new Notification.Builder(context);
        }
        builder.setSmallIcon(R.drawable.address_book_father_big);
        builder.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.address_book_father_big));
        builder.setContentTitle("语音通讯");
        builder.setContentText(str);
        builder.setWhen(System.currentTimeMillis());
        Notification notification = builder.build();
        notification.flags = Notification.FLAG_NO_CLEAR;
        return notification;
//        manager.notify(0,notification);
    }
}
